package com.课上案例练习.线程.等待唤醒机制.线程等待.两个线程通信;

public class Show2 implements Runnable{
    int flag = 1;//标识
    Object object=  new Object();

    public Show2(int flag, Object object) {
        this.flag = flag;
        this.object = object;
    }

    @Override
    public void run() {
        if(flag==1){
            for (int i = 0; i < 3; i++) {
              synchronized ( object){
                  System.out.print("我");
                  System.out.print("想");
                  System.out.print("看");
                  System.out.print("看");
                  System.out.println();
              }
            }
        }
        else if(flag==0){
            for (int i = 0; i < 3; i++) {
           synchronized (object){
               System.out.print("世");
               System.out.print("界");
               System.out.print("那");
               System.out.print("么");
               System.out.print("大");
               System.out.println();
           }
            }
        }
    }
}
